home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / STRINGS / PACKAGE6 / COPY.DOC < prev    next >
Text File  |  1990-07-25  |  3KB  |  65 lines

  1. ------------------------------------------------------------------------------
  2. CopyString
  3. ------------------------------------------------------------------------------
  4.  
  5.  
  6. declaration:     procedure CopyString (    OriginalString:
  7.                                              TypeString;
  8.                                            NumberOfChracters,
  9.                                            Position:
  10.                                              integer;
  11.                                        var ResultString:
  12.                                              TypeString);
  13.  
  14. purpose:         Returns a portion of a string (original) in another
  15.                  string (result).
  16.  
  17. preconditions:   OriginalString was originally initiialized.
  18.                  NumberOfCharacters has been a given a meaningfull value.
  19.                  Position has been given a meaningfull value.
  20.                  ResultString may be undefined.
  21.  
  22. postconditions:  ResultString is filled with the desired number of characters
  23.                  from the original string from left to right starting from
  24.                  the position in the original string designated by
  25.                  Position.
  26.  
  27. special cases:   -where Position > 0
  28.                  -if NumberOfCharacters + Position >= OriginalString._Length
  29.                   then ResultString = the characters in
  30.                   OriginalString._PackedArray starting at Position until the
  31.                   Counter > OriginalString._Length.
  32.                  -if NumberOfCharacters <= 0 then ResultString._Length = 0 and
  33.                   ResultString._PackedArray is not changed.
  34.                  -if Position <= 0 then ResultString._Length = 0 and
  35.                   ResultString._PackedArray is not changed.
  36.  
  37. example:         var
  38.                    OriginalString,
  39.                    ResultString:
  40.                      TypeString;
  41.                    NumberOfCharacters,
  42.                    Position:
  43.                      integer;
  44.                    LastKey:
  45.                      TypeKey;
  46.  
  47.                  begin
  48.                    .
  49.                    .
  50.                    .
  51.                    ReadlnString (OriginalString, MaxStringLength, LastKey);
  52.                    NumberOfCharacters:= 2;
  53.                    Position:= 3;
  54.                    CopyString (OriginalString, NumberOfCharacters, Position,
  55.                                ResultString);
  56.                    write(output,'The third and fourth characters are ==>> ');
  57.                    WriteString (ResultString);
  58.                    writeln(output,'.');
  59.                    .
  60.                    .
  61.                    .
  62.                  end
  63.  
  64. ------------------------------------------------------------------------------
  65.